﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using BioBooking.Data;
using BioBooking.Data.CtrLag;

namespace BioBooking.Server
{
    public class Service : IRepository
    {
        MovieController mc = new MovieController();
        ShowingController sc = new ShowingController();
        BookingController bk = new BookingController();
        MemberController mem = new MemberController();

        public List<Movie> ListAllActiveMovies()
        {
            return mc.listAllMovies();
        }

        public List<Movie> GetMoviesByShowingsDate(DateTime date)
        {
            return mc.getMoviesByDate(date);
        }

        public List<Showing> GetShowsFromShowtime(int movieID)
        {
            return sc.getMoviesFromShowtime(movieID);
        }

        public Movie GetMovieByID(int movieID)
        {
            return mc.SearchMovie(movieID);
        }

        public Showing GetShow(int showingID)
        {
            return sc.getShow(showingID);
        }

        public void InsertMovie(string titel, DateTime releaseDate, string instructor, string actors, string originalTitle, string country, string language, string description,Int32 runtime, Genre genre)
        {
            mc.InsertMovie(titel, releaseDate, instructor, actors, originalTitle, country, language, description, runtime, genre);
        }

        public void InsertMovieObject(Movie movie)
        {
            mc.insertMovie(movie);
        }

        public List<Genre> GetAllGenres()
        {
            return mc.GetAllGenres();
        }

        public void UpdateMovie(int key, string titel, DateTime releaseDate, string instructor, string actors, string originalTitle, string country, string language, string description,Int32 runtime, Genre genre)
        {
            mc.UpdateMovie(key, titel, releaseDate, instructor, actors, originalTitle, country, language, description, runtime, genre);
        }

        public void UpdateMovieObject(Movie movie)
        {
            mc.UpdateMovieObject(movie);
        }

        public void DeleteMovie(Movie movie)
        {
            mc.DeleteMovie(movie);
        }

        public List<Cinema> GetCinemas()
        {
            return sc.getCinemas();
        }

        public void CreateShowingObject(Showing showing)
        {
            sc.CreateShowingObject(showing);
        }

        public void CreateShowing(DateTime startTime, DateTime endTime, decimal unitPrice, DateTime date, Movie movie, Cinema cinema)
        {
            sc.createShowing(startTime, endTime, unitPrice, date, movie, cinema);
        }

        public Movie GetMovieFromShowing(Showing show)
        {
            return show.Movie;
        }

        public void CreateBooking(Showing show, Member member, List<Seat> seats, bool paymentReceived = false)
        {
            bk.CreateBooking(show, seats, member, false);
        }

        public void DeleteBooking(Booking booking)
        {
            bk.DeleteBooking(booking);
        }

        public void UpdateBooking(Booking booking)
        {
            bk.UpdateBooking(booking);
        }

        public bool ReserveSeats(List<Seat> seats, Showing showing)
        {
            return bk.ReserveSeats(seats, showing);
        }

        public void RefreshLockedSeats()
        {
            //bk.RefreshLockedSeats();
        }

        public List<Showing> GetAllShowings()
        {
            return sc.getAllShowings();
        }

        public List<Member> ListAllMembers()
        {
            return mem.listAllMembers();
        }

        public void CreateMemberObject(Member member)
        {
            mem.CreateMemberObject(member);
        }

        public void UpdateMemberObject(Member member)
        {
            mem.UpdateMemberObject(member);
        }

        public void SetDiscount(bool discount, int memberID)
        {
            mem.SetDiscount(discount, memberID);
        }

        public void SetCounter(Int32 counter, int memberID)
        {
            mem.SetCounter(counter, memberID);
        }
    }
}
